/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    2013 year
 *    Author: Esipenko Aleksey (Alexorleon)
 *    E-Mail: alexorleon@gmail.com
 */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QCloseEvent>
#include <QString>
#include <QtSql>
#include <QTextDocument>
#include "pageData.h"

class TableModel;
class ProxyModel;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
protected:
    void closeEvent(QCloseEvent *event);

private:
    Ui::MainWindow *ui;

    void createConnections();
    void requestdatabase(const QString &req);
    void requestPerformers();
    void requestPlacements();
    void exportDoc(const bool &isSelect, const QItemSelection &item);

    TableModel *model;
    ProxyModel *proxyModel;

    QSqlDatabase database;

    void setCurrentDate();
    QString mainRequest;

    PageData pageData;

    QList<int> parameters;
    QSettings *settings;
    void loadSettings();
    void saveSettings();
private slots:

    void slot_newQRcode();
    void slot_newPerformer();
    void slot_newPlacement();
    void slot_newHistory();
    void slot_newContact();
    void slot_exportToFile();
    void slot_deleteQR();
    void slot_sample();
    void slot_saveImage();
    void slot_settings();
    void slot_about();

    void slot_viewQRText();

    // date
    void slot_changeDate_s();
    void slot_changeDate_po();

    void slot_resetDate();
};

#endif // MAINWINDOW_H
